home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_olv_jag2.cog < prev    next >
Text File  |  1999-11-15  |  9KB  |  371 lines

  1. # Jones 3D Cog Script
  2. #
  3. # olv_jag2.cog   
  4. #
  5. # [SCHOLL]
  6. #
  7. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ========================================================================================
  10. symbols
  11.  
  12. message entered
  13. message    startup
  14. message    aievent
  15. message    arrivedwpnt
  16. message timer
  17. message user0
  18. message user1
  19.  
  20. thing    t_Jag        
  21. thing    t_Indy        local
  22.  
  23. int        b_Operational=1    local
  24. int        n_eventType        local
  25. int        n_CrntAIMode     local
  26. int        n_OldAIMode     local
  27. int        n_Waypoint        local
  28. int        n_Temp            local
  29. int        b_Temp            local
  30. flex    f_Temp            local
  31. flex    f_DistToIndy    local 
  32. int        n_TimerID        local 
  33. int        b_OKToStopFlee=0 local
  34. int        n_idx            local
  35. int        b_WpntsActive=0    local
  36.  
  37. vector    v_IndyPos        local
  38. vector    v_JagPos        local
  39. vector    v_JagToIndy        local
  40. vector    v_IndyLook        local
  41. vector    v_Temp            local
  42.  
  43.  
  44.  
  45. # ===========================FLEE WAYPOINTS================================================
  46. int            NUM_FLEE_WAYPOINTS=25            local
  47. thing        t_Waypoint00
  48. thing        t_Waypoint01
  49. thing        t_Waypoint02
  50. thing        t_Waypoint03
  51. thing        t_Waypoint04
  52. thing        t_Waypoint05
  53. thing        t_Waypoint06
  54. thing        t_Waypoint07
  55. thing        t_Waypoint08
  56. thing        t_Waypoint09
  57. thing        t_Waypoint10
  58. thing        t_Waypoint11
  59. thing        t_Waypoint12
  60. thing        t_Waypoint13
  61. thing        t_Waypoint14
  62. thing        t_Waypoint15
  63. thing        t_Waypoint16
  64. thing        t_Waypoint17
  65. thing        t_Waypoint18
  66. thing        t_Waypoint19
  67. thing        t_Waypoint20
  68. thing        t_Waypoint21
  69. thing        t_Waypoint22
  70. thing        t_Waypoint23
  71. thing        t_Waypoint24
  72.  
  73.  
  74. # ===========================SECTORS================================================
  75.  
  76. int            NUM_AUTO_FLEE_SECTORS=7     local
  77. sector        s_AutoFlee00            mask=0x5 # need entered messages from jag
  78. sector        s_AutoFlee01            mask=0x5 # need entered messages from jag
  79. sector        s_AutoFlee02            mask=0x5 # need entered messages from jag
  80. sector        s_AutoFlee03            mask=0x5 # need entered messages from jag
  81. sector        s_AutoFlee04            mask=0x5 # need entered messages from jag
  82. sector        s_AutoFlee05            mask=0x5 # need entered messages from jag
  83. sector        s_AutoFlee06            mask=0x5 # need entered messages from jag
  84.  
  85. int            NUM_ACTIVATE_WPNT_SECTORS=7 local
  86. sector        s_ActivateWpnts00
  87. sector        s_ActivateWpnts01
  88. sector        s_ActivateWpnts02
  89. sector        s_ActivateWpnts03
  90. sector        s_ActivateWpnts04
  91. sector        s_ActivateWpnts05
  92. sector        s_ActivateWpnts06
  93.  
  94. int            NUM_DEACTIVATE_WPNT_SECTORS=3 local
  95. sector        s_DeactivateWpnts00
  96. sector        s_DeactivateWpnts01
  97. sector        s_DeactivateWpnts02
  98.  
  99.  
  100. # ===========================MISC CONSTANTS================================================
  101.  
  102. flex    MIN_FLEE_DISTANCE=2.0            local # distance jag wants to be from Indy before stopping fleeing
  103. flex    MAX_FLEEATTACK_DISTANCE=1.0            local # 
  104. flex    MIN_FLEE_TIME=4.0                local 
  105. flex    VARIABLE_FLEE_TIME=3.0            local
  106.  
  107. int        TIMER_ID_OKAY_TO_STOP_FLEE=0    local
  108. int        TIMER_ID_START_FLEE=1            local
  109.  
  110.  
  111.     flex        activatewaypoints            local
  112.     flex        deactivatewaypoints        local
  113.     int        f_fleetime                local
  114.     flex        setdisttoindy            local
  115.  
  116.  
  117. end
  118. # ========================================================================================
  119.  
  120. code
  121. startup:
  122.     t_Indy=GetLocalPlayerThing();
  123.  
  124.     return;
  125.  
  126. # ========================================================================================
  127. entered:
  128.     if (!b_Operational)
  129.     {
  130.         return;
  131.     }
  132.     
  133.     if (GetSourceRef() == t_Indy)
  134.     {
  135.         for (n_idx = 0; n_idx < NUM_ACTIVATE_WPNT_SECTORS; n_idx = n_idx + 1)
  136.         {
  137.             if (GetSenderRef() == s_ActivateWpnts00[n_idx])
  138.             {
  139.                 call ActivateWaypoints;
  140.             }
  141.         }
  142.         for (n_idx = 0; n_idx < NUM_DEACTIVATE_WPNT_SECTORS; n_idx = n_idx + 1)
  143.         {
  144.             if (GetSenderRef() == s_DeactivateWpnts00[n_idx])
  145.             {
  146.                 call DeactivateWaypoints;
  147.             }
  148.         }
  149.     }
  150.     else if (GetSourceRef() == t_Jag)
  151.     {
  152.         for (n_idx = 0; n_idx < NUM_AUTO_FLEE_SECTORS; n_idx = n_idx + 1)
  153.         {
  154.             if (GetSenderRef() == s_AutoFlee00[n_idx])
  155.             {
  156.                 AIFlee(t_Jag, t_Indy);
  157.             }
  158.         }
  159.     }
  160.     return;
  161.  
  162. # ========================================================================================
  163. aievent:
  164.     if (!b_Operational)
  165.     {
  166.         return;
  167.     }
  168.     
  169.     n_eventType        = GetParam(0);
  170.     n_CrntAIMode    = GetParam(1);
  171.     n_OldAIMode        = GetParam(2);    // only valid for certain n_eventType values
  172.  
  173.     if (n_eventType == 0x100)        // SITHAI_EVENTMODECHANGED
  174.     {
  175.         // if changing to flee mode
  176.         // turn on waypoints
  177.         if ( !BITTEST(n_OldAIMode, 0x800) && BITTEST(n_CrntAIMode, 0x800) )
  178.         {
  179.             AISetSubMode(t_Jag, 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION
  180.             f_FleeTime = (MIN_FLEE_TIME + (Rand() * VARIABLE_FLEE_TIME));
  181.             SetTimerEx(f_FleeTime , TIMER_ID_OKAY_TO_STOP_FLEE, 0, 0 );
  182.             b_OKToStopFlee = 0;
  183.         }
  184.         // if exiting flee mode
  185.         // turn off waypoints
  186.         else if ( BITTEST(n_OldAIMode, 0x800) && !BITTEST(n_CrntAIMode, 0x800) )
  187.         {
  188.             call SetDistToIndy;
  189.         
  190.             // Consider restarting fleeing if Indy to close, but jag hasn't chose to surprise attack
  191.             if ( (f_DistToIndy < MIN_FLEE_DISTANCE) && !BITTEST(AIGetMode(t_Jag), 0x2))
  192.             {
  193.                 // Restart using timer to avoid nested mode changes
  194.                 SetTimerEx(0.01 , TIMER_ID_START_FLEE, 0, 0 );
  195.             }
  196.             else
  197.             {
  198.                 AIClearSubMode(t_Jag, 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION
  199.             }
  200.         }
  201.     }
  202.  
  203. return;
  204.  
  205. # ========================================================================================
  206. timer:
  207.     if (!b_Operational)
  208.     {
  209.         return;
  210.     }
  211.  
  212.     t_Indy = GetLocalPlayerThing();
  213.  
  214.     n_TimerID = GetSenderID();
  215.     if (n_TimerID == TIMER_ID_OKAY_TO_STOP_FLEE)
  216.     {
  217.         b_OKToStopFlee = 1;
  218.     }
  219.     else if (n_TimerID == TIMER_ID_START_FLEE)
  220.     {
  221.         AIFlee(t_Jag, t_Indy);
  222.     }
  223.  
  224.     return;
  225.  
  226.  
  227. # ========================================================================================
  228. arrivedwpnt:
  229.     if (!b_Operational)
  230.     {
  231.         return;
  232.     }
  233.  
  234.     n_Waypoint = GetParam(0);
  235.  
  236.     call SetDistToIndy;
  237.  
  238.     if ( b_OKToStopFlee 
  239.          && (f_DistToIndy > MIN_FLEE_DISTANCE)
  240.          && BITTEST(AIGetMode(t_Jag), 0x800) // fleeing
  241.          && (RandBetween(0,100) < 90)
  242.          )
  243.     {
  244.         // StopThing before StopFlee so jaguar will turn to face indy
  245.         StopThing(t_Jag);
  246.         AIStopFlee(t_Jag);
  247.     }
  248.     else if ( b_OKToStopFlee 
  249.          && (f_DistToIndy < MAX_FLEEATTACK_DISTANCE)
  250.          && BITTEST(AIGetMode(t_Jag), 0x800) // fleeing
  251.          && (RandBetween(0,100) < 30)
  252.          )
  253.     {
  254.         AISetFireTarget(t_Jag, t_Indy);
  255.     }
  256.  
  257.     return;
  258.  
  259. # ========================================================================================
  260. user0:
  261.     b_Operational = 0;
  262.     SetThingFlags(t_Jag, 0x80000);
  263.     AISetMode(t_Jag, 0x2000);
  264.     return;
  265.  
  266. # ========================================================================================
  267. user1:
  268.     if (!b_Operational)
  269.     {
  270.         return;
  271.     }
  272.     AIFlee(t_Jag, t_Indy);
  273.     return;
  274.  
  275. # ========================================================================================
  276.  
  277.  
  278.  
  279. SetDistToIndy:
  280.     v_IndyPos = GetThingPos(t_Indy);
  281.     v_JagPos = GetThingPos(t_Jag);
  282.  
  283.     f_DistToIndy = VectorDist(v_IndyPos, v_JagPos);
  284.  
  285.     return;
  286.  
  287. # ========================================================================================
  288. ActivateWaypoints:
  289.     if (b_WpntsActive)
  290.     {
  291.         return;
  292.     }
  293.  
  294.     b_WpntsActive = 1;
  295.     AISetInstinctWpntMode(t_Jag);
  296.  
  297.     for ( n_idx = 0; n_idx < NUM_FLEE_WAYPOINTS; n_idx = n_idx + 1 )
  298.     {
  299.         AISetWpnt(t_Waypoint00[n_idx], n_idx);
  300.     }
  301.  
  302.     AIConnectWpnts(0, 1);
  303.     AIConnectWpnts(0, 2);
  304.     AIConnectWpnts(0, 4);
  305.     AIConnectWpnts(1, 3);
  306.     AIConnectWpnts(1, 4);
  307.     AIConnectWpnts(2, 4);
  308.     AIConnectWpnts(2, 5);
  309.     AIConnectWpnts(2, 8);
  310.     AIConnectWpnts(3, 4);
  311.     AIConnectWpnts(3, 6);
  312.     AIConnectWpnts(3, 7);
  313.     AIConnectWpnts(4, 6);
  314.     AIConnectWpnts(4, 7);
  315.     AIConnectWpnts(5, 8);
  316.     AIConnectWpnts(5, 9);
  317.     AIConnectWpnts(6, 7);
  318.     AIConnectWpnts(6, 10);
  319.     AIConnectWpnts(6, 11);
  320.     AIConnectWpnts(7, 8);
  321.     AIConnectWpnts(7, 10);
  322.     AIConnectWpnts(7, 11);
  323.     AIConnectWpnts(8, 9);
  324.     AIConnectWpnts(8, 12);
  325.     AIConnectWpnts(8, 13);
  326.     AIConnectWpnts(9, 13);
  327.     AIConnectWpnts(10, 11);
  328.     AIConnectWpnts(10, 14);
  329.     AIConnectWpnts(11, 12);
  330.     AIConnectWpnts(11, 14);
  331.     AIConnectWpnts(12, 13);
  332.     AIConnectWpnts(12, 14);
  333.     AIConnectWpnts(14, 15);
  334.     AIConnectWpnts(15, 16);
  335.     AIConnectWpnts(16, 17);
  336.     AIConnectWpnts(17, 18);
  337.     AIConnectWpnts(17, 19);
  338.     AIConnectWpnts(18, 19);
  339.     AIConnectWpnts(18, 20);
  340.     AIConnectWpnts(18, 21);
  341.     AIConnectWpnts(18, 22);
  342.     AIConnectWpnts(19, 21);
  343.     AIConnectWpnts(19, 22);
  344.     AIConnectWpnts(20, 21);
  345.     AIConnectWpnts(20, 23);
  346.     AIConnectWpnts(21, 22);
  347.     AIConnectWpnts(21, 23);
  348.     AIConnectWpnts(21, 24);
  349.     AIConnectWpnts(22, 24);
  350.     AIConnectWpnts(23, 24);
  351.  
  352.     return;
  353.  
  354. # ========================================================================================
  355. DeactivateWaypoints:
  356.     if (!b_WpntsActive)
  357.     {
  358.         return;
  359.     }
  360.  
  361.     b_WpntsActive = 0;
  362.     AIClearInstinctWpntMode(t_Jag);
  363.     StopThing(t_Jag);
  364.  
  365.     return;
  366.  
  367.  
  368.  
  369. end
  370.  
  371.